// ==UserScript==
// @name           shnflac filter
// @namespace      http://code.google.com/p/shnflac-filter/
// @description    Removes torrent rows from popular lossless music sites
// @include        http://bt.etree.org/index.ph*
// @include        http://www.shnflac.net/torrents.ph*
// @include        http://gdvault.com/tracker/torrents.ph*
// @require        http://code.jquery.com/jquery-1.3.2.min.js
// ==/UserScript==

$(document).ready(function() {

   var add_css = '<style type="text/css">#filter-box {position: absolute; top: 0; left: 0; z-index: 10; background:#ffc; padding:5px; border:1px solid #CCCCCC;width: 100%;display: inline;filter:alpha(opacity=75);opacity: 0.75;} .hidden{display: none;}.filt{display: inline;color: green;} #filter-clear {margin-right: 10px;} #filter-hide {float:right; margin-right: 20px;}</style>';

   var the_box = '<div id="filter-box"><form action="" id="filter-form"><input type="text" title="filter torrents" name="filter_text" id="filter-input" /><input type="submit" value="add filter" id="filter-submit" name="filter-submit" /><input type="reset" value="clear filters" id="filter-clear" name="filter-submit" /><div id="filter-hide"><input type="submit" value="hide" id="xout" name="xout" /></div></form></div>';
  
   $('head').append(add_css); // add new css and html
   $('body').append(the_box);

   $(window).scroll(function() {  // scroll the filter
      $('#filter-box').animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 50});
   });
   
   $('#filter-submit').click(function (f) {  // takes input, and filters torrent rows
      f.preventDefault();
      var inputted_filter = $('#filter-input').val();
      $('a:contains('+inputted_filter+')').closest('tr').addClass('hidden');
      $('#filter-input').val('');
      $('#filter-form').append('<div class="filt">"' +inputted_filter+ '"</div> ');
      
   });
   
   $('#filter-clear').click(function (cl) { // clears filters
      cl.preventDefault();
      $('tr.hidden').removeClass('hidden');
      $('div.filt').remove();
   });
   
   $('#xout').click(function (xo) { // hides filters
      xo.preventDefault();
      $('#filter-box').slideUp('1000');
   });
   
   $('#filter-input').focus();
   
});

	  